﻿using Connection.IView;
using Connection.Presenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace RemoChat
{
    /// <summary>
    /// Interaction logic for WinInviChat.xaml
    /// </summary>
    public partial class WinInviChat : Window, IWinInviChatView
    {
        string URL;
        string _fromUsername;
        public WinInviChat()
        {
            InitializeComponent();
        }

        public WinInviChat(string url)
        {
            InitializeComponent();
            URL = url;
        }

        public WinInviChat(string url, string fromusername)
        {
            InitializeComponent();
            URL = url;
            this.FromUsername = fromusername;
        }

        public string ToUsername
        {
            get { return txtUsernameInvi.Text; }
            set { txtUsernameInvi.Text = value; }
        }


        public string FromUsername
        {
            get { return _fromUsername; }
            set { _fromUsername = value; }
        }

        private void btnOkInvi_Click(object sender, RoutedEventArgs e)
        {
            InviPresenter inviPresenter = (InviPresenter)Activator.GetObject(typeof(InviPresenter), URL + "PRESENTER/INVIPRESENTER_OBJECT");
            inviPresenter.Test();
            if (inviPresenter.IsInviOk(this.ToUsername))
            {
                WinChat winchat = new WinChat(URL, this.ToUsername, this.FromUsername);
                winchat.Show();
                this.Close();
            }
            else
                MessageBox.Show("That Bai");
        }
    }
}
